#!/usr/bin/make -f

package=gimp-mayaiff
object=MayaIFF
gimp_version=2.6
install_gimp_version=2.0
root=debian/tmp
gimptool=gimptool-2.0

build:
	$(checkdir)
	$(gimptool) --build src/$(object).c

clean:
	rm -fr *~ src/*~ $(root) debian/*~ debin/files* debian/substvars

binary-indep:	checkroot build
	$(checkdir)

binary-arch:	checkroot build
	rm -fr $(root)
	install -d $(root)/DEBIAN\
		-d $(root)/usr/share/doc/$(package)\
		-d $(root)/usr/lib/gimp/$(install_gimp_version)/plug-ins\
		-d $(root)/usr/share/gimp/scripts\
		-d $(root)/usr/bin/
	strip $(object)
	cp $(object) $(root)/usr/lib/gimp/$(install_gimp_version)/plug-ins
	cp README* $(root)/usr/share/doc/$(package)/.
	cp ChangeLog $(root)/usr/share/doc/$(package)/changelog
	gzip -9 $(root)/usr/share/doc/$(package)/changelog
	cp debian/changelog $(root)/usr/share/doc/$(package)/changelog.Debian
	gzip -9 $(root)/usr/share/doc/$(package)/changelog.Debian
	cp debian/copyright $(root)/usr/share/doc/$(package)/.
	dpkg-shlibdeps $(object)
	rm $(object)
	dpkg-gencontrol -isp
	chown -R root.root $(root)
	chmod -R g-ws $(root)
	dpkg --build $(root) ..
	rm -fr $(root)

define checkdir
	test -f src/$(object).c -a -f debian/rules
endef

binary:	binary-indep binary-arch

checkroot:
	$(checkdir)
	test root = "`whoami`"

.PHONY:	binary binary-arch binary-indep clean checkroot
